/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * articulos_sie_add.java
 *
 * Created on 18/02/2011, 10:16:27 AM
 */

package sie_invdis;
import java.sql.*;
import javax.swing.*;

import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTable.*;
import java.awt.*;

/**
 *
 * @author Michelle
 */
public class articulos_sie_add extends javax.swing.JDialog {

        private int tiendasel=0;
        private float existencia=0;
        private int indexjtapestana=0;
        private int fidtienda=0,controlcombo=0;
        private JTable jtable_tiendas;
        bd_conexion x = new bd_conexion() ;

        ResultSet rs = null;
    /** Creates new form articulos_sie_add */
    public articulos_sie_add(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        // x.estableceConexion();
        this.setLocation(250,100);
         
       
        this.jtf_clave.requestFocus();
        this.loadcombo();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel9 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jtf_subfamilia = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jtf_familia = new javax.swing.JTextField();
        jtf_precio = new javax.swing.JTextField();
        jtf_costo = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jtf_descripcion = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jtf_item = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jtf_clave = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jtf_codigo_barra = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jta_archivo = new javax.swing.JTextArea();
        jbtn_importar = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jbtn_helpayuda = new javax.swing.JButton();
        jbtn_salir = new javax.swing.JButton();
        jbtn_guardar = new javax.swing.JButton();
        jcbx_tiendas = new javax.swing.JComboBox();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jmni_salir = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jmni_escape = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jmni_crearcomentario = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(sie_invdis.Sie_invdisApp.class).getContext().getResourceMap(articulos_sie_add.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jtf_subfamilia.setText(resourceMap.getString("jtf_subfamilia.text")); // NOI18N
        jtf_subfamilia.setToolTipText(resourceMap.getString("jtf_subfamilia.toolTipText")); // NOI18N
        jtf_subfamilia.setName("jtf_subfamilia"); // NOI18N
        jtf_subfamilia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_subfamiliaActionPerformed(evt);
            }
        });

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jtf_familia.setText(resourceMap.getString("jtf_familia.text")); // NOI18N
        jtf_familia.setToolTipText(resourceMap.getString("jtf_familia.toolTipText")); // NOI18N
        jtf_familia.setName("jtf_familia"); // NOI18N
        jtf_familia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_familiaActionPerformed(evt);
            }
        });

        jtf_precio.setText(resourceMap.getString("jtf_precio.text")); // NOI18N
        jtf_precio.setName("jtf_precio"); // NOI18N
        jtf_precio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_precioActionPerformed(evt);
            }
        });

        jtf_costo.setText(resourceMap.getString("jtf_costo.text")); // NOI18N
        jtf_costo.setName("jtf_costo"); // NOI18N
        jtf_costo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_costoActionPerformed(evt);
            }
        });

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jtf_descripcion.setText(resourceMap.getString("jtf_descripcion.text")); // NOI18N
        jtf_descripcion.setName("jtf_descripcion"); // NOI18N
        jtf_descripcion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_descripcionActionPerformed(evt);
            }
        });

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jtf_item.setText(resourceMap.getString("jtf_item.text")); // NOI18N
        jtf_item.setName("jtf_item"); // NOI18N
        jtf_item.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_itemActionPerformed(evt);
            }
        });

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jtf_clave.setText(resourceMap.getString("jtf_clave.text")); // NOI18N
        jtf_clave.setName("jtf_clave"); // NOI18N
        jtf_clave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_claveActionPerformed(evt);
            }
        });

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jtf_codigo_barra.setText(resourceMap.getString("jtf_codigo_barra.text")); // NOI18N
        jtf_codigo_barra.setToolTipText(resourceMap.getString("jtf_codigo_barra.toolTipText")); // NOI18N
        jtf_codigo_barra.setName("jtf_codigo_barra"); // NOI18N
        jtf_codigo_barra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtf_codigo_barraActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_clave, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 157, Short.MAX_VALUE)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtf_codigo_barra, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jtf_descripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 304, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jtf_item, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(56, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(71, 71, 71)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jtf_precio, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtf_costo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE)
                            .addComponent(jtf_familia, javax.swing.GroupLayout.Alignment.LEADING)))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel8)
                            .addGap(18, 18, 18)
                            .addComponent(jtf_subfamilia, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE))
                        .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING)))
                .addGap(482, 482, 482))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(50, 50, 50)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jtf_clave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jtf_codigo_barra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(46, 46, 46)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtf_item, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jtf_descripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(58, 58, 58)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jtf_costo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(40, 40, 40)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jtf_precio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(29, 29, 29)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jtf_familia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(42, 42, 42)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jtf_subfamilia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(33, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N

        jPanel2.setName("jPanel2"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jta_archivo.setColumns(20);
        jta_archivo.setRows(5);
        jta_archivo.setName("jta_archivo"); // NOI18N
        jScrollPane3.setViewportView(jta_archivo);

        jbtn_importar.setIcon(resourceMap.getIcon("jbtn_importar.icon")); // NOI18N
        jbtn_importar.setText(resourceMap.getString("jbtn_importar.text")); // NOI18N
        jbtn_importar.setName("jbtn_importar"); // NOI18N
        jbtn_importar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_importarActionPerformed(evt);
            }
        });

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(34, 34, 34)
                        .addComponent(jbtn_importar))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 410, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 464, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel10)
                .addGap(33, 33, 33)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(209, 209, 209)
                .addComponent(jbtn_importar)
                .addContainerGap(30, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel2.TabConstraints.tabTitle"), jPanel2); // NOI18N

        jPanel3.setName("jPanel3"); // NOI18N

        jbtn_helpayuda.setIcon(resourceMap.getIcon("jbtn_helpayuda.icon")); // NOI18N
        jbtn_helpayuda.setText(resourceMap.getString("jbtn_helpayuda.text")); // NOI18N
        jbtn_helpayuda.setName("jbtn_helpayuda"); // NOI18N
        jbtn_helpayuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_helpayudaActionPerformed(evt);
            }
        });

        jbtn_salir.setIcon(resourceMap.getIcon("jbtn_salir.icon")); // NOI18N
        jbtn_salir.setText(resourceMap.getString("jbtn_salir.text")); // NOI18N
        jbtn_salir.setName("jbtn_salir"); // NOI18N
        jbtn_salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_salirActionPerformed(evt);
            }
        });

        jbtn_guardar.setIcon(resourceMap.getIcon("jbtn_guardar.icon")); // NOI18N
        jbtn_guardar.setText(resourceMap.getString("jbtn_guardar.text")); // NOI18N
        jbtn_guardar.setName("jbtn_guardar"); // NOI18N
        jbtn_guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtn_guardarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jbtn_guardar)
                .addGap(69, 69, 69)
                .addComponent(jbtn_salir)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 93, Short.MAX_VALUE)
                .addComponent(jbtn_helpayuda)
                .addGap(80, 80, 80))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(12, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtn_guardar)
                    .addComponent(jbtn_salir)
                    .addComponent(jbtn_helpayuda)))
        );

        jcbx_tiendas.setToolTipText(resourceMap.getString("jcbx_tiendas.toolTipText")); // NOI18N
        jcbx_tiendas.setName("jcbx_tiendas"); // NOI18N
        jcbx_tiendas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbx_tiendasActionPerformed(evt);
            }
        });

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem1.setIcon(resourceMap.getIcon("jMenuItem1.icon")); // NOI18N
        jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jmni_salir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK));
        jmni_salir.setIcon(resourceMap.getIcon("jmni_salir.icon")); // NOI18N
        jmni_salir.setText(resourceMap.getString("jmni_salir.text")); // NOI18N
        jmni_salir.setName("jmni_salir"); // NOI18N
        jmni_salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_salirActionPerformed(evt);
            }
        });
        jMenu1.add(jmni_salir);

        jMenuBar1.add(jMenu1);

        jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
        jMenu2.setName("jMenu2"); // NOI18N

        jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_PAGE_DOWN, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem3.setIcon(resourceMap.getIcon("jMenuItem3.icon")); // NOI18N
        jMenuItem3.setText(resourceMap.getString("jMenuItem3.text")); // NOI18N
        jMenuItem3.setName("jMenuItem3"); // NOI18N
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem3);

        jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_PAGE_UP, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem4.setIcon(resourceMap.getIcon("jMenuItem4.icon")); // NOI18N
        jMenuItem4.setText(resourceMap.getString("jMenuItem4.text")); // NOI18N
        jMenuItem4.setName("jMenuItem4"); // NOI18N
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem4);

        jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem5.setText(resourceMap.getString("jMenuItem5.text")); // NOI18N
        jMenuItem5.setName("jMenuItem5"); // NOI18N
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem5);

        jMenuItem6.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem6.setText(resourceMap.getString("jMenuItem6.text")); // NOI18N
        jMenuItem6.setName("jMenuItem6"); // NOI18N
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem6);

        jMenuItem7.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem7.setText(resourceMap.getString("jMenuItem7.text")); // NOI18N
        jMenuItem7.setName("jMenuItem7"); // NOI18N
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem7);

        jMenuItem8.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem8.setText(resourceMap.getString("jMenuItem8.text")); // NOI18N
        jMenuItem8.setName("jMenuItem8"); // NOI18N
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem8);

        jmni_escape.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0));
        jmni_escape.setText(resourceMap.getString("jmni_escape.text")); // NOI18N
        jmni_escape.setName("jmni_escape"); // NOI18N
        jmni_escape.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_escapeActionPerformed(evt);
            }
        });
        jMenu2.add(jmni_escape);

        jMenuBar1.add(jMenu2);

        jMenu3.setText(resourceMap.getString("jMenu3.text")); // NOI18N
        jMenu3.setName("jMenu3"); // NOI18N

        jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK));
        jMenuItem2.setIcon(resourceMap.getIcon("jMenuItem2.icon")); // NOI18N
        jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem2);

        jmni_crearcomentario.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, java.awt.event.InputEvent.ALT_MASK));
        jmni_crearcomentario.setText(resourceMap.getString("jmni_crearcomentario.text")); // NOI18N
        jmni_crearcomentario.setName("jmni_crearcomentario"); // NOI18N
        jmni_crearcomentario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmni_crearcomentarioActionPerformed(evt);
            }
        });
        jMenu3.add(jmni_crearcomentario);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jcbx_tiendas, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 653, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jcbx_tiendas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 446, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jmni_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_salirActionPerformed
        // TODO add your handling code here:
          if(JOptionPane.showConfirmDialog(null, "Desea Salir?")==0)
              {
                this.dispose();
              }
        
    }//GEN-LAST:event_jmni_salirActionPerformed

    private void jbtn_guardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_guardarActionPerformed
        // TODO add your handling code here:
if(JOptionPane.showConfirmDialog(null, "Estan Correctos sus Datos?")==0)
      {
        this.guarda_articulo();
      }
    else
    {
        this.jtf_clave.requestFocus();
    }


    }//GEN-LAST:event_jbtn_guardarActionPerformed

    private void guarda_articulo()
       {
        float vcos=0,vprecio=0;
        int vfam=0,vsubfam=0;
            String vclave = this.jtf_clave.getText().toUpperCase().trim();
            String vcodigo = this.jtf_codigo_barra.getText().toUpperCase().trim();
            String vdescrip = this.jtf_descripcion.getText().toUpperCase().trim();
            try{
                    vcos = Float.valueOf(this.jtf_costo.getText().toString());
               }catch (NumberFormatException nfe)
               {
                   vcos=0;
               }
            try{
                    vprecio = Float.valueOf(this.jtf_precio.getText().toString());
               }catch (NumberFormatException nfe)
               {
                   vprecio=0;
               }

            try{

                    vfam = Integer.parseInt(this.jtf_familia.getText().toString());

               }catch (NumberFormatException nfe)
               {
                   vfam=0;
               }

            try{
                    vsubfam = Integer.parseInt(this.jtf_subfamilia.getText().toString());
               }catch (NumberFormatException nfe)
               {
                   vsubfam=0;
               }
            String vitem = this.jtf_item.getText().toUpperCase().trim();
            if( (vprecio > 0) && (vclave.length() > 0) && (vdescrip.length() > 0))
                {
                   //rs = x.damecat_art_addsie(vclave,vcodigo,vdescrip,vcos,vprecio,vfam,vsubfam,vitem,existencia,tiendasel);
                    String arreglo_idtie[]=null;
                   arreglo_idtie=this.jcbx_tiendas.getSelectedItem().toString().split(":");
                   tiendasel=Integer.valueOf(arreglo_idtie[0]);
                   
                   String texto="select * from x1sieuno_addarticulo('"+vclave+"','"+vcodigo+"','"+vdescrip+"',"+vcos+","+vprecio+","+vfam+","+vsubfam+",'"+vitem+"',"+existencia+","+tiendasel+") as (status smallint)";
                   System.out.println(texto);
                    try {
                    rs = x.sieuno_executediversosv2(texto,variables_global.getconexiongral());
                     while (rs.next())
                            {

                         }
                    } catch(Exception e)
                        {
                              System.out.println(e.getMessage());

                        }

                    this.jtf_clave.setText("");
                    this.jtf_codigo_barra.setText("");
                    this.jtf_descripcion.setText("");
                    this.jtf_costo.setText("0");
                    this.jtf_precio.setText("0");
                    this.jtf_clave.requestFocus();
                }
            else
                {
                    JOptionPane.showMessageDialog(null,"Verifique datos de articulo", "Sistema Integral(Agrear) : Ayuda",1);
                    this.jtf_clave.requestFocus();
                }
        }
    private void jtf_claveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_claveActionPerformed
        // TODO add your handling code here:
        this.jtf_codigo_barra.requestFocus();
    }//GEN-LAST:event_jtf_claveActionPerformed

    private void jtf_codigo_barraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_codigo_barraActionPerformed
        // TODO add your handling code here:
        this.jtf_descripcion.requestFocus();
    }//GEN-LAST:event_jtf_codigo_barraActionPerformed

    private void jtf_descripcionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_descripcionActionPerformed
        // TODO add your handling code here:
        this.jtf_item.requestFocus();
    }//GEN-LAST:event_jtf_descripcionActionPerformed

    private void jtf_itemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_itemActionPerformed
        // TODO add your handling code here:
        this.jtf_costo.requestFocus();
    }//GEN-LAST:event_jtf_itemActionPerformed

    private void jtf_costoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_costoActionPerformed
        // TODO add your handling code here:
        this.jtf_precio.requestFocus();
    }//GEN-LAST:event_jtf_costoActionPerformed

    private void jtf_precioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_precioActionPerformed
        // TODO add your handling code here:
        this.jtf_familia.requestFocus();
    }//GEN-LAST:event_jtf_precioActionPerformed

    private void jtf_familiaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_familiaActionPerformed
        // TODO add your handling code here:
        this.jtf_subfamilia.requestFocus();
    }//GEN-LAST:event_jtf_familiaActionPerformed

    private void jtf_subfamiliaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtf_subfamiliaActionPerformed
        // TODO add your handling code here:
        this.jbtn_guardar.requestFocus();
    }//GEN-LAST:event_jtf_subfamiliaActionPerformed

    private void jbtn_salirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_salirActionPerformed
        // TODO add your handling code here:
         //x.cierraConexion();
        this.dispose();
    }//GEN-LAST:event_jbtn_salirActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        this.jbtn_guardarActionPerformed(evt);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        this.ayuda();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jbtn_helpayudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_helpayudaActionPerformed
        // TODO add your handling code here:
        this.ayuda();
    }//GEN-LAST:event_jbtn_helpayudaActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        // TODO add your handling code here:
       // this.jrbtn_all.requestFocus();
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        // TODO add your handling code here:
        this.jtf_clave.requestFocus();
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        // TODO add your handling code here:
        this.jTabbedPane1.setSelectedIndex(0);
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        // TODO add your handling code here:
        this.jTabbedPane1.setSelectedIndex(1);
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        // TODO add your handling code here:
        if (indexjtapestana==1)
            {
                indexjtapestana=0;
             }
        else
            {
                indexjtapestana+=1;
             }


         this.jTabbedPane1.setSelectedIndex(indexjtapestana);

    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        // TODO add your handling code here:
       if (indexjtapestana==0)
            {
                indexjtapestana=1;
             }
        else
            {
                indexjtapestana-=1;
             }

         this.jTabbedPane1.setSelectedIndex(indexjtapestana);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jmni_crearcomentarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_crearcomentarioActionPerformed
        // TODO add your handling code here:
        this.crearcomentario();
    }//GEN-LAST:event_jmni_crearcomentarioActionPerformed

    private void jbtn_importarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtn_importarActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null, "Desea Importar Estos Articulos?")==0)
            {
                    String arreglo_importa[]=this.jta_archivo.getText().split("\n");
                    String arreglo_codigo[]=null;
                    System.out.println("Estos tiene archivo:"+arreglo_importa.length);
                    for (int i=0;i<arreglo_importa.length;i++)
                        {
                            arreglo_codigo=arreglo_importa[i].split("\t");
                            this.jtf_clave.setText(arreglo_codigo[0]);
                            this.jtf_codigo_barra.setText(arreglo_codigo[1]);
                            this.jtf_descripcion.setText(arreglo_codigo[2]);
                            this.jtf_item.setText(arreglo_codigo[7]);
                            this.jtf_costo.setText(arreglo_codigo[3]);
                            this.jtf_precio.setText(arreglo_codigo[4]);
                            this.jtf_familia.setText(arreglo_codigo[5]);
                            this.jtf_subfamilia.setText(arreglo_codigo[6]);
                            //this.jbtn_guardarActionPerformed(evt);
                            System.out.println("articulo:"+arreglo_codigo[0]);
                            this.guarda_articulo();
                        }
                    this.jta_archivo.setText("");
            }
}//GEN-LAST:event_jbtn_importarActionPerformed

    private void jcbx_tiendasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbx_tiendasActionPerformed
        // TODO add your handling code here:




        if (controlcombo > 0 ) {
            if(JOptionPane.showConfirmDialog(null, "Estan Correctos sus Datos?")==0) {
            
            }
            
        }


        //this.jtfpruebados.setText(jtable_tiendas.getValueAt(indeceta, 0).toString());
}//GEN-LAST:event_jcbx_tiendasActionPerformed

    private void jmni_escapeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmni_escapeActionPerformed
        // TODO add your handling code here:
        this.jmni_salirActionPerformed(evt);
    }//GEN-LAST:event_jmni_escapeActionPerformed
private  void ayuda()
            {
                String punto1="1.-Agregar articulos a catalogos,cada una de las Opciones se autodescribe brevemente\n";
                String punto2="2.- Cada Boton tiene Una letra Resaltada el cual indica su metodo abreviado, uselo si desea mayor rapides ( ejemplo Alt+a obtendra ayuda automaticamente)\n";
                String punto3="3.- Para Desplazarse en la pantalla use las teclas de acceso rapido ejemplo Alt + t o AVG PAGINA Y REPAG en el caso de las pestañas. \n ";
                JOptionPane.showMessageDialog(null,""+punto1+punto2+punto3+"", "Sistema Integral(Agregando Articulos) : Ayuda",1);
            }

private void crearcomentario()
          {
                 String retorno="";

        String comentario=JOptionPane.showInputDialog("Ingresa Tu Sugerencia o Comentario:");
        if (comentario.length()>0)
        {
            rs = x.sieuno_executediversosv2("select * from x1distribucion_bitacorainserta('"+comentario+"', 'Articulos: Agregar');",variables_global.getconexiongral());
            try
            {

               while (rs.next())
                    {
                         retorno=rs.getString(1);
                   }
             }
            catch(Exception e)
            {
                System.out.println(e.getMessage());
            }
            if (retorno.equals("1"))
              {
                JOptionPane.showMessageDialog(null,"Gracias Tu comentario ha sido guardado", "Sistema Integral Comentarios",1);

              }

      }
    }

private void loadcombo(){
        jtable_tiendas=variables_global.gettabla_tiendas();
         int numerotiendas=this.jtable_tiendas.getRowCount();
         this.jcbx_tiendas.addItem("0:Todas las Tiendas");
          for(int ii=0;ii<numerotiendas;ii++)
                        {
                            this.jcbx_tiendas.addItem(jtable_tiendas.getValueAt(ii, 1)+":"+jtable_tiendas.getValueAt(ii, 0));
                        }
         this.jcbx_tiendas.addItem("7:almacen Central");
         this.jcbx_tiendas.addItem("8:Fit");
    }
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                articulos_sie_add dialog = new articulos_sie_add(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton jbtn_guardar;
    private javax.swing.JButton jbtn_helpayuda;
    private javax.swing.JButton jbtn_importar;
    private javax.swing.JButton jbtn_salir;
    private javax.swing.JComboBox jcbx_tiendas;
    private javax.swing.JMenuItem jmni_crearcomentario;
    private javax.swing.JMenuItem jmni_escape;
    private javax.swing.JMenuItem jmni_salir;
    private javax.swing.JTextArea jta_archivo;
    private javax.swing.JTextField jtf_clave;
    private javax.swing.JTextField jtf_codigo_barra;
    private javax.swing.JTextField jtf_costo;
    private javax.swing.JTextField jtf_descripcion;
    private javax.swing.JTextField jtf_familia;
    private javax.swing.JTextField jtf_item;
    private javax.swing.JTextField jtf_precio;
    private javax.swing.JTextField jtf_subfamilia;
    // End of variables declaration//GEN-END:variables

}
